ShinyStudio

Overview

ShinyStudio is a Docker image which extends rocker/verse to include RStudio, Shiny Server, VS Code, and ShinyProxy.

ShinyStudio leverages ShinyProxy to provide:

  • a centralized, pre-configured development environment.
  • a centralized repository for documents written in Markdown, RMarkdown, or HTML.
  • a simple and secure method for sharing web apps developed with RStudio Shiny.

The ShinyStudio image consists of the products described below:

Flavors

The ShinyStudio stack has been verified to work on native Docker, as well as Docker Desktop for Mac and Windows.

The GitHub repo for the ShinyStudio image is used to build the image published on DockerHub. The image is great for a personal instance, a quick demo, or the building blocks for a very customized setup.

https://github.com/dm3ll3n/ShinyStudio-Image

The repo for the enhanced setup of ShinyStudio builds upon the base image to provide an example of a more enterprise-ready instance of ShinyStudio, including NGINX, InfluxDB, and control scripts.

https://github.com/dm3ll3n/ShinyStudio

Setup from DockerHub

Setup must not be run as ‘root’.

First, create a network named shinystudio-net to be shared by all spawned containers.

docker network create shinystudio-net

Then, pull and run the ShinyStudio image directly from DockerHub.

Linux / Mac (Bash)

docker run --rm -it --name shinyproxy \
    --network shinystudio-net \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -e USERID=$USERID \
    -e USER=$USER \
    -e PASSWORD=password \
    -e CONTENTPATH="${HOME}/ShinyStudio" \
    -e SITEID=default \
    -p 8080:8080 \
    dm3ll3n/shinystudio

Windows (PowerShell)

docker run --rm -it --name shinyproxy `
    --network shinystudio-net `
    -v /var/run/docker.sock:/var/run/docker.sock `
    -e USERID=1000 `
    -e USER=$env:USERNAME `
    -e PASSWORD=password `
    -e CONTENTPATH="/host_mnt/c/Users/$env:USERNAME/ShinyStudio" `
    -e SITEID=default `
    -p 8080:8080 `
    dm3ll3n/shinystudio

Notice the unique form of the path for the CONTENTPATH variable in the Windows setup.

Once complete, open a web browser and navigate to http://<hostname>:8080. Log in with your username and the password password.

Variables:

Variable Default Explained
USERID $USERID For proper permissions, this value should not be changed.
USER $USER Username to use at the ShinyProxy login screen.
PASSWORD password Password to use at the ShinyProxy login screen.
CONTENTPATH “${HOME}/ShinyStudio” The path to store site content and user settings.
SITEID default Defines the folder name that this site’s content will reside in ($CONTENTPATH/sites/$SITEID).
ROOT false Grant root permission in RStudio / VS Code? Useful for testing, but changes are not persistent.

Setup from GitHub

The enhanced ShinyStudio setup requires Docker, docker-compose, and Git.

Setup must be run as a non-root user.

# Clone the master branch.
git clone https://github.com/dm3ll3n/ShinyStudio

# Enter the new directory.
cd ShinyStudio

Linux / Mac (Bash)

./control.sh setup

Windows (PowerShell)

./control.ps1 setup

The default CONTENTPATH is $PWD/content. To specify another CONTENTPATH, pass the desired path as an argument to the setup:

./control.[sh|ps1] setup "$HOME/ShinyStudio"

Once complete, open a web browser and navigate to http://<hostname>:8080.

The default logins are:

username password
user user
admin admin
superadmin superadmin

Develop

Open your IDE of choice and notice two important directories:

  • __ShinyStudio__
  • __Personal__

Files must be saved in either of these two directories in order to persist between sessions.

These two folders are shared between instances RStudio, VS Code, and Shiny Server. So, creating new content is as simple as saving a file to the appropriate directory.

Tools

The ShinyStudio image comes with…

  • R
  • Python 3
  • PowerShell

…and ODBC drivers for:

  • SQL Server
  • PostgresSQL
  • Cloudera Impala.

These are persistent because they are built into the image.

Persistent
__ShinyStudio__ directory Yes
__Personal__ directory Yes
Other directories No
R Libraries Yes
Python Packages Yes
PowerShell Modules Yes
RStudio User Settings Yes
VS Code User Settings Yes
Installed Apps No
Installed Drivers No

Advanced Configuration

The information below applies only to the “enhanced” setup on GitHub.

Security

Authentication is managed by ShinyProxy, which supports basic auth, LDAP, Kerberos, and others (read more).

By default, ShinyStudio defines three levels of access:

  • readers: can only view content from “Apps & Reports”, “Documents”, and “Personal”.
  • admins: can view all site content and develop content with RStudio and VS Code.
  • superadmins: can view and develop site content across multiple instances of ShinyStudio.

Admin / SuperAdmin landing page:

Readers:

To apply a custom security configuration, modify the ShinyProxy configuration file for the site. All available options are detailed in the docs for ShinyProxy.

./sites/8080_Site1.yml

The site config files should follow the covention "{SITEPORT}_{SITEID}.yml“, where”SITEPORT" is the port to host the site, and “SITEID” is a unique idenfifier for the site.

Open 8080_Site1.yml and edit the following lines as desired:

authentication: simple
users:
  - name: superadmin
    password: *change*me*
    groups: superadmins
  - name: admin
    password: *change*me*
    groups: admins
  - name: user
    password: *change*me*
    groups: readers

To enforce LDAP authentication, use:

ldap:
    url: ldap://mydomain.com/DC=mydomain,DC=com
    manager-dn: CN=svc.user,OU=Users,DC=mydomain,DC=com
    manager-password: ...
    user-search-base: 
    user-search-filter: (sAMAccountName={0})
    group-search-base: OU=Groups
    group-search-filter: (member={0})

After modifying any part of the configuration, stop and re-setup the site with:

# Linux / Mac
./control.sh setup "<CONTENTPATH>"

# Windows
./control.ps1 setup "<CONTENTPATH>"

Multiple Sites

Multiple instances of ShinyProxy can be mapped to different ports in order to segment content or provide unique customizations.

The configs below will setup two unique, independent instances of ShinyStudio, hosted on ports 8080, 8081.

./sites/8080_Site1.yml
./sites/8081_Site2.yml

Shared Content

It is possible to have multiple sites with independent configurations have access to the same content. To do this, name the file PORT_SITEID.yml, where PORT is the port to broadcast on, and SITEID is the SITEID of the site that already has content.

./sites/8080_Site1.yml
./sites/8081_Site1.yml